Guided Practice 6.2: A Different Kind of Tree
Consider a data structure of trees that have leaves with numbers in
them, and two kinds of interior nodes: one kind with two sons and the
other kind with three sons. Here's an example:
These trees are similar, but not identical to what are usually called
2-3 trees.
- Write a data definition for these trees, including a template
and a halting measure.
- Write leaf-max for these trees.
- Write a function double-all that takes one of these
trees and returns a tree of the same shape in which all the leaves
are doubled. For example, double-all applied to the tree above
should return the tree
[ANSWER]
(Remember, you won't get
anything about of this exercise unless you actually write the code and
test it.)
Last modified: Mon Sep 5 22:41:27 Eastern Daylight Time 2016